**The following syntax will reproduce the results in Ascencio and Kerevel, "Party Strategy, Candidate Selection,
*and Legislative Behavior in Mexico," published in Legislative Studies Quarterly.

***Main results
*H1: Model 1, Table 2
poisson defection_noabst i.appointedmed i.copartisangov i.electiongober i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair  if  alternate==0 & partyswitcher==0, robust
estat ic
margins appointedmed, asobserved post
ereturn list
*Figure 1
marginsplot, plotopts(connect(none))

*H2: Model 2, Table 2
poisson defection_noabst c.margin_prev2  i.copartisangov i.electiongober  i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair if  alternate==0 & partyswitcher==0 & selectiontier==0, robust
estat ic
*H1 & H2: Model 3, Table 2
poisson defection_noabst i.selectiontier c.margin_prev2 i.selectiontier#c.margin_prev2  i.copartisangov i.electiongober  i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair if  alternate==0 & partyswitcher==0, robust
estat ic
margins selectiontier, at(margin_prev2=(-0.35(0.01)0.5)) vsquish post
*Figure 2
marginsplot, recast(line) recastci(rarea)

*The following syntax will reproduce the results available in the Online Appendix to Ascencio and Kerevel.

***Appendix Models
*Defection from caucus leader
*Model 1, Table A1
poisson defection_coord i.appointedmed i.copartisangov i.electiongober i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair  if  alternate==0 & partyswitcher==0, robust
estat ic
*Model 2, Table A1
poisson defection_coord c.margin_prev2  i.copartisangov i.electiongober  i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair if  alternate==0 & partyswitcher==0 & selectiontier==0, robust
estat ic
*Model 3, Table A1
poisson defection_coord i.selectiontier c.margin_prev2 i.selectiontier#c.margin_prev2  i.copartisangov i.electiongober  i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair if  alternate==0 & partyswitcher==0, robust
estat ic
margins selectiontier, at(margin_prev2=(-0.35(0.01)0.5)) vsquish post
*Figure A1a
marginsplot, recast(line) recastci(rarea)

*Defections, including abstentions
*Model 4, Table A1
poisson defection i.appointedmed i.copartisangov i.electiongober i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair  if  alternate==0 & partyswitcher==0, robust
estat ic
*Model 5, Table A1
poisson defection c.margin_prev2  i.copartisangov i.electiongober  i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair if  alternate==0 & partyswitcher==0 & selectiontier==0, robust
estat ic
*Model 6, Table A1
poisson defection i.selectiontier c.margin_prev2 i.selectiontier#c.margin_prev2  i.copartisangov i.electiongober  i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair if  alternate==0 & partyswitcher==0, robust
estat ic
margins selectiontier, at(margin_prev2=(-0.35(0.01)0.5)) vsquish post
*Figure A1b
marginsplot, recast(line) recastci(rarea)

*Percentage of defection votes across all possible votes 
*Model 7, Table A1
reg per_defection_ab i.appointedmed i.copartisangov i.electiongober i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair  if  alternate==0 & partyswitcher==0
estat ic
*Model 8, Table A1
reg per_defection_ab c.margin_prev2  i.copartisangov i.electiongober  i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair if  alternate==0 & partyswitcher==0 & selectiontier==0
estat ic
*Model 9, Table A1
reg per_defection_ab i.selectiontier c.margin_prev2 i.selectiontier#c.margin_prev2  i.copartisangov i.electiongober  i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair if  alternate==0 & partyswitcher==0
estat ic
margins selectiontier, at(margin_prev2=(-0.35(0.01)0.5)) vsquish post
*Figure A1c
marginsplot, recast(line) recastci(rarea)

*Abstentions only
*Figure A1d
poisson abstain i.selectiontier c.margin_prev2 i.selectiontier#c.margin_prev2  i.copartisangov i.electiongober  i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair if  alternate==0 & partyswitcher==0, robust
margins selectiontier, at(margin_prev2=(-0.35(0.01)0.5)) vsquish post
marginsplot, recast(line) recastci(rarea)

*Absences only
*Figure A1e
poisson absent i.selectiontier c.margin_prev2 i.selectiontier#c.margin_prev2  i.copartisangov i.electiongober  i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair if  alternate==0 & partyswitcher==0, robust
margins selectiontier, at(margin_prev2=(-0.35(0.01)0.5)) vsquish post
marginsplot, recast(line) recastci(rarea)

*Defections, Abstentions and Absences
*Figure A1f
poisson defectabstainabsent i.selectiontier c.margin_prev2 i.selectiontier#c.margin_prev2  i.copartisangov i.electiongober  i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair if  alternate==0 & partyswitcher==0, robust
margins selectiontier, at(margin_prev2=(-0.35(0.01)0.5)) vsquish post
marginsplot, recast(line) recastci(rarea)

**Figure A2
*Figure A2a
poisson defection_noabst i.appointed1 i.copartisangov i.electiongober i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair  if  alternate==0 & partyswitcher==0, robust
margins appointed1, asobserved
marginsplot, plotopts(connect(none))

*Figure A2b
poisson defection_noabst i.appointed5 i.copartisangov i.electiongober i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair  if  alternate==0 & partyswitcher==0, robust
margins appointed5, asobserved
marginsplot, plotopts(connect(none))

*Figure A2c
poisson defection_noabst i.appointedmed i.copartisangov i.electiongober i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair  if  alternate==0 & partyswitcher==0, robust
margins appointedmed, asobserved
marginsplot, plotopts(connect(none))

*Figure A2d
poisson defection_noabst i.appointed10 i.copartisangov i.electiongober i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair  if  alternate==0 & partyswitcher==0, robust
margins appointed10, asobserved
marginsplot, plotopts(connect(none))

*Figure A2e
poisson defection_noabst i.appointed15 i.copartisangov i.electiongober i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair  if  alternate==0 & partyswitcher==0, robust
margins appointed15, asobserved
marginsplot, plotopts(connect(none))

*Figure A2f
poisson defection_noabst i.appointed20 i.copartisangov i.electiongober i.congress_cat i.party_cat ///
educ_level2 age leg_exp_dum female committeechair  if  alternate==0 & partyswitcher==0, robust
margins appointed20, asobserved
marginsplot, plotopts(connect(none))

